// pages/shop/qr.js
var app = getApp();
Page({
  data:{},
  onLoad:function(options){
    // 页面初始化 options为页面跳转所带来的参数
  },
  onReady: function(){
    var shop = wx.getStorageSync('shop');
    shop.logo = shop.logo.replace(/(^\s*)|(\s*$)/g, "");
    shop.qrcode = shop.qrcode.replace(/(^\s*)|(\s*$)/g, "");
    this.setData({
      shop: shop
    })
  },
  previewImage:function(){
    var url = this.data.shop.qrcode;
    //添加图片预览
    wx.previewImage({
      urls: [url]
    })
  },
  onShareAppMessage: function () {
    var that = this;
    return {
      title: '你的朋友分享了'+that.data.shop.name,
      imageUrl: that.data.shop.logo.replace(/(^\s*)|(\s*$)/g, ""),
      path: 'pages/share/share?shop_id=' + that.data.shop.id + '&products_share=true'
    }
  },
  shopLink: function(){
    var that = this;
    var url = 'pages/share/share?shop_id=' + that.data.shop.id + '&products_share=true';
    wx.setClipboardData({
      data: url,
      success: function (res) {
        wx.showToast({
          title: '复制成功！',
          icon: 'success',
          duration: 2000,
          mask: true
        })
      }
    });
  }
})
